﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NF_Tools
{
    public partial class BF_TitleMenu : UserControl
    {
        public BF_TitleMenu()
        {
            InitializeComponent();
        }

        private Image _DafuteImage;
        private Font _TextFont;
        private string _TitleText;
        private bool _IsFocus = false;


        [Category("Ternence"), Description("默认图标")]
        public Image DafuteImage
        {
            get
            {
                return _DafuteImage;
            }
            set
            {
                _DafuteImage = value;
                this.picIco.Image = _DafuteImage;
            }
        }

        [Category("Ternence"), Description("文字字体")]
        public Font TextFont
        {
            get
            {
                _TextFont = this.lblTitle.Font;
                return _TextFont;
            }
            set
            {
                _TextFont = value;
                lblTitle.Font = _TextFont;
            }
        }

        [Category("Ternence"), Description("菜单文字")]
        public string TitleText
        {
            get
            {
                _TitleText = this.lblTitle.Text.Trim();
                return _TitleText;
            }
            set
            {
                _TitleText = value;
                this.lblTitle.Text = value;
            }
        }

        [Category("Ternence"), Description("得到焦点图标")]
        public Image HoverImage { get; set; }

        [Category("Ternence"), Description("失去焦点图标")]
        public Image LevelImage { get; set; }

         [Category("Ternence"), Description("当前焦点")]
         public bool IsFocus
         {
             get { return _IsFocus; }
             set 
             {
                 _IsFocus = value;
                 if (!_IsFocus)
                 {
                     this.picIco.Image = LevelImage;
                     this.lblTitle.ForeColor = Color.FromArgb(90, 90, 90);
                 }
                 else
                 {
                     this.picIco.Image = HoverImage;
                     this.lblTitle.ForeColor = Color.FromArgb(233, 81, 29);
                 }
                     
             }
         }

        private void MouseEnter(object sender, EventArgs e)
        {
            this.picIco.Image = HoverImage;
            this.lblTitle.ForeColor = Color.FromArgb(233, 81, 29);
        }

        /// <summary>
        /// 鼠标离开
        /// </summary>
        private void MoveseLevel(object sender, EventArgs e)
        {
            if (IsFocus) return;
            this.picIco.Image = LevelImage;
            this.lblTitle.ForeColor = Color.FromArgb(90, 90, 90);
        }


        public delegate void MenuClickEventHanld(object sender, EventArgs e);
        public event MenuClickEventHanld MenuClickEvent;

        /// <summary>
        /// 单机得到焦点
        /// </summary>
        private void ClickIOCAndLable(object sender, EventArgs e)
        {
            if (MenuClickEvent != null)
                MenuClickEvent(this, e);
        }




    }
}
